package com.example.pcl.controller.counselor;


import com.example.pcl.constant.MessageConstants;
import com.example.pcl.exception.ObjectException;
import com.example.pcl.result.Result;
import com.example.pcl.service.ICounselorsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 心理咨询师表，存储心理咨询师个人信息 前端控制器
 * </p>
 *
 * @author xx
 * @since 2024-12-17
 */
@RestController("counselorCounselorsController")
@RequestMapping("/user/counselor")
@Tag(name = "管理端心理咨询师相关接口")
@Slf4j
@RequiredArgsConstructor
public class CounselorsController {
    private final ICounselorsService counselorService;


    // 获取心理咨询师的预约统计数据
    @GetMapping("/stats/{counselorId}")
    @Operation(summary = "获取心理咨询师预约统计数据", description = "获取心理咨询师的待确认预约数、已完成预约数、好评率等统计信息")
    public Result<?> getConsultationStats(@PathVariable Integer counselorId) {
        try {
            return Result.success(counselorService.getConsultationStatsByCounselor(counselorId), MessageConstants.SELECT_OK);
        } catch (Exception e) {
            throw new ObjectException("获取失败");
        }
    }


    @GetMapping("/stats2/{id}")
    @Operation(summary = "获取心理咨询师预约统计数据2")
    public Result<?> getConsultationVolumeByCounselor(@PathVariable Integer id) {
        return Result.success(counselorService.getConsultationVolumeByCounselor(id), MessageConstants.SELECT_OK);
    }
}
